//
//  EnterpriseDisplayViewController.m
//  DaMaoMall
//
//  Created by HXHL-wally on 16/8/8.
//  Copyright © 2016年 daMao-wally. All rights reserved.
//

#import "EnterpriseDisplayViewController.h"
#import "EenterpriseDisplayTableViewCell.h"
#import "EenterpriseSectionView.h"

@interface EnterpriseDisplayViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UITableView * enterpriseTV;
@property (nonatomic, strong) NSArray * titleArray;

@end

@implementation EnterpriseDisplayViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.titleLabel.text = @"公司信息";
    self.titleArray = @[@"",@"联系方式",@"公司内容",@"公司信息"];
    [self setUpTableview];
    
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)setUpTableview{
    
    UITableView * enterpriseTV = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, GetScreenWidth, GetScreenHeight-64) style:UITableViewStyleGrouped];
    self.enterpriseTV = enterpriseTV;
    self.enterpriseTV.delegate = self;
    self.enterpriseTV.dataSource = self;
    self.enterpriseTV.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.contentView addSubview:self.enterpriseTV];
    
}
#pragma mark - TableView dalegate,datesource
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        return  63.0f;
    }
    return 47.0f;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    CGFloat adViewH = GetScreenHeight * 0.2578;
    if (section == 0) {
        return adViewH;
    }else{
        return  47.0f;
    }

}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.01f;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView * headerView = [[UIView alloc]init];
    headerView.backgroundColor = [UIColor clearColor];
    switch (section) {
        case 0:{
            UIImageView * imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, GetScreenWidth, GetScreenHeight*0.2578)];
            imageView.image =[UIImage imageNamed:@"placeholder"];
            [headerView addSubview:imageView];
            break;
        }
        case 1:{
            EenterpriseSectionView * eenterprise = [[EenterpriseSectionView alloc]init];
            eenterprise.title.text = self.titleArray[section];
            [headerView addSubview:eenterprise];
            break;
        }
        case 2:{
            EenterpriseSectionView * eenterprise = [[EenterpriseSectionView alloc]init];
            eenterprise.title.text = self.titleArray[section];
            [headerView addSubview:eenterprise];
            break;
        }
        case 3:{
            EenterpriseSectionView * eenterprise = [[EenterpriseSectionView alloc]init];
            eenterprise.title.text = self.titleArray[section];
            [headerView addSubview:eenterprise];
            break;
        }
            
        default:
            break;
    }
    return headerView;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return self.titleArray.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString * cellStr = @"enterprise";
    EenterpriseDisplayTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellStr];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle]loadNibNamed:@"EenterpriseDisplayTableViewCell" owner:nil options:nil]lastObject];
        if (indexPath.row == 0) {
            
        }else{
            
        }
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}


@end
